<template>
  <div>
    <el-form ref="form" :model="form"  label-width="100px" >
            <el-row>
              <el-col :span="12" >
              <el-form-item label="处理老师"  class="form_item_bottom">
                    <span>{{form.removeUserName}}</span>
              </el-form-item>
              </el-col>
              <el-col :span="12">
              <el-form-item label="处理时间" class="form_item_bottom">
                {{form.removeTime}}
              </el-form-item>
              </el-col>
            </el-row>
              <el-col :span="24">
              <el-form-item label="备案材料" class="form_item_bottom">
                <UploadCom ref="handUpload" :disabled="form.isRemove==1"  @submitData="handSubmitData" :userFileList="fileList"
                style="width: 500px;"/>
              </el-form-item>
              </el-col>
              </el-row>
              <el-col :span="24">
              <el-form-item label="备注说明" class="form_item_bottom">
                 <el-input  type="textarea" v-model="form.removeMark" rows="4" placeholder="请输入备注说明" v-if="form.isRemove!=1" />
                 <span v-if="form.isRemove==1">{{form.removeMark}}</span>
              </el-form-item>
              </el-col>
              </el-row>
           </el-form>
  </div>
</template>

<script>
import { getBlackPersonnel, updateBlackPersonnel} from "@/api/labdata/blackPersonnel";
import { formatCurrentDate } from "@/utils/index";
import UploadCom from "@/views/labdata/commons/upload.vue";
export default {
  name: "RemoveBlack",
  components:{UploadCom},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
     //附件集合
     fileList: [],
     // 查询参数
     queryParams: {
       pageNum: 1,
       pageSize: 10,
       userName: null,
     },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  props:{
    id:Number,
  },
  watch:{
    id:function(val){
      if(val)
      this.getBlackPersonInfo(val);
    },
  },
  created() {
    this.getBlackPersonInfo(this.id);
  },
  methods: {
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    getBlackPersonInfo(id){
      getBlackPersonnel(id).then(response=>{
        if(response.data.isRemove==1){
          this.form = response.data;
          this.fileList = this.form.images;
        }else{
          this.reset();
        }
      })
    },
    // 表单重置
    reset() {
      this.fileList = [];
      this.form = {};
      this.form.removeUserName = this.$store.state.user.nickName;
      this.form.removeTime = formatCurrentDate();
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 提交按钮 */
      handSubmitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            this.$refs["handUpload"].doSubmit();
          }
        });
      },
      /** 提交按钮 */
      handSubmitData(fileList) {
        this.form.images = fileList;
        this.form.id = this.$props.id;
        if(!this.form.id){
          this.$message.error("错误，不能获取到用户黑名单ID.");
          return;
        }
        updateBlackPersonnel(this.form).then(response => {
          this.msgSuccess("黑名单移除成功");
          this.$emit("operation");
        });
      },
  }
};
</script>
<style scoped lang="scss">
 /* .form_item_bottom{
    margin-bottom: 5px;
  } */
  /*
  /deep/ .el-upload-list__item-name {
    margin-top: -40px;
  }*/
</style>
